<template>
  <div class="home-swiper">
    <swiper :options="swiperOption" v-if="bannersInit">
      <swiper-slide v-for='item of banners' :key="item.url">
        <a :href="item.url" class="swiper-href">
          <img class="swiper-img" :src="item.imageUrl">
        </a>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    banners: Array
  },
  data () {
    return {
      swiperOption: {
        spaceBetween: 5,
        autoplay: 5000,
        pagination: '.swiper-pagination',
        effect: 'coverflow',
        loop: true,
        centeredSlides: true,
        coverflowEffect: {
          rotate: 10,
          stretch: 10,
          depth: 60,
          modifier: 2,
          slideShadows: true
        }
      }
    }
  },
  computed: {
    bannersInit () {
      return this.banners.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .home-swiper >>> .swiper-pagination {
    bottom: 0.1rem;
    .swiper-pagination-bullet {
      width: 0.1rem;
      height: 0.1rem;
      background: #fff;
      border-radius: 50%;
      opacity: 0.8;
      &.swiper-pagination-bullet-active {
        opacity: 1;
        width: 0.26rem;
        border-radius: 0.04rem;
      }
    }
  }
  .home-swiper {
    width: 100%;
    margin: 0 auto;
    height: 37.037037vw;
    margin-top: 0.25rem;
    text-align: center;
    .swiper-href {
      display: block;
      width: 100%;
      height: 100%;
    }
    .swiper-img {
      width: 92%;
      border-radius: 0.1rem;
    }
  }
</style>
